class AddCountries < ActiveRecord::Migration
  def self.up
    change_table :editions do |t|
      t.remove :place_id
      t.integer :country_id
    end

    change_table :labels do |t|
      t.remove :place_id
      t.integer :city_id
      t.integer :country_id
    end

    add_foreign_key(:editions, :countries, :column => :country_id)
    add_foreign_key(:labels, :countries, :column => :country_id)
    add_foreign_key(:labels, :cities, :column => :city_id)
  end

  def self.down
    change_table :editions do |t|
      t.remove :country_id
      t.integer :place_id
    end

    change_table :labels do |t|
      t.remove :country_id
      t.remove :city_id
      t.integer :place_id
    end

    remove_foreign_key(:editions, :column => :country_id)
    remove_foreign_key(:labels, :column => :country_id)
    remove_foreign_key(:labels, :column => :city_id)
  end
end
